import React, { FC } from 'react';
import styles from './index.less';

interface InjectProps {
  /** 图表模块标题 */
  title: string;
}

const ChartWrapper = <T extends {}>(WrappedComponent: FC<T>): FC<T & InjectProps> => {
  return (props: T & InjectProps) => {
    const { title } = props;

    return (
      <div className={styles.chartWrapper}>
        {title ? <div className={styles.title}>{title}</div> : null}
        <WrappedComponent {...props} />
      </div>
    );
  };
};

export default ChartWrapper;
